import { createRouter, createWebHashHistory } from 'vue-router'

import Layout from '@/layout/LayoutView'
// component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
// 路由规则
const routes = [
  // 一级路由
  {
    path: '/',
    component: Layout,
    // 二级路由
    children: [
      // 首页
      { path: '/', component: () => import('@/views/home/HomeView') },
      // 一级分类
      { path: '/category/:id', component: () => import('@/views/category/CategoryView') },
      // 二级分类
      { path: '/category/sub/:id', component: () => import('@/views/category/sub/SubCategoryView') }
    ]
  }
]

// 创建路由实例 createRouter()
const router = createRouter({
  // 使用Hash实现路由
  history: createWebHashHistory(),
  // 配置路由规则
  routes
})

// 导出路由实例
export default router
